//
//  CellInvite.m
//  FB_skd
//
//  Created by Le Thanh Hai on 4/21/13.
//  Copyright (c) 2013 Le Thanh Hai. All rights reserved.
//

#import "CellInvite.h"

@implementation CellInvite

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(IBAction)invitePress:(id)sender
{
    NSString *message = @"join game with me, together play";
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"apprequest", @"type", @"true", @"new_style_message", message, @"message", self.facebookId, @"to", nil];
    [[[ShareFacebook shareInstance] facebook] dialog:@"apprequests" andParams:params andDelegate:self];
}

#pragma mark - FBDialogDelegate
- (void)dialogCompleteWithUrl:(NSURL *)url
{
    NSLog(@"url : %@", [url absoluteString]);
    
    NSString *urlString = [url absoluteString];
    NSRange range = [urlString rangeOfString:@"request"];
    if (range.location != NSNotFound) {
//        inviteButton.enabled = NO;
//        [inviteButton setImage:[UIImage imageNamed:@"FriendInvite11.png"] forState:UIControlStateNormal];
//        
//        NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
//        NSString *userFBID = [userDefault objectForKey:@"userFBID"];
//        NSMutableDictionary *invitedFBFriends = [[userDefault objectForKey:[NSString stringWithFormat:@"invitedFBFriends_%@", userFBID]] mutableCopy];
//        if (!invitedFBFriends)
//            invitedFBFriends = [NSMutableDictionary new];
//        [invitedFBFriends setObject:@"invited" forKey:tmpFriendID];
//        [userDefault setObject:invitedFBFriends forKey:[NSString stringWithFormat:@"invitedFBFriends_%@", userFBID]];
//        [userDefault synchronize];
    }
}

@end
